1
'****************************** Module Header ******************************\
2 ' Module Name: GlobalResources.aspx.vb
3 ' Project: VBASPNETLocalization
4 ' Copyright (c) Microsoft Corporation
6 ' The project illustrates how to build a multi-lingual website with ASP.NET
7 ' Localization. ASP.NET enables pages obtain content and other data based
8 ' on the preferred language setting of the browser or based on the user's
9 ' explicit choice of language. If controls are configured to get property
10 ' values from resources, at run time, the resource expressions are replaced
11 ' by resources from the appropriate resource file.
13 ' This page describes how to use Global Resources files to make controls in
14 ' different pages share consistent resource data. When we reach Page2.aspx
15 ' from Default.aspx, we can find only [lblGlobal] is displayed in correct
16 ' text and color while [lblLocal] with the totally same HTML code as it
17 ' is in LocalResources.aspx doesn't. It is because [lblLocal] is localized
18 ' by Local Resources while [lblGlobal] is based on data in Global Resources
21 ' This source is subject to the Microsoft Public License.
22 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
23 ' All other rights reserved.
26 ' * 7/27/2009 7:20 PM Bravo Yang Created
27 '***************************************************************************/
29 #Region
"Imports Directory"
30 Imports System
.Threading
31 Imports System
.Globalization
35 Partial
Public Class GlobalResources
36 Inherits System
.Web
.UI
.Page
38 Protected Overrides
Sub InitializeCulture()
40 ' Get the user's selection from DropDownList by Request.Form().
41 ' This value is passed from Defualt.aspx by form's action attribute
42 ' because we use PostBackUrl property of the Button to do the
43 Dim strLanguageInfo
As String = Request
.Form("ddlLanguage")
45 If Not strLanguageInfo Is
Nothing Then
46 ' Set the CurrentUICulture and CurrentCulture to strLanguageInfo.
47 Thread
.CurrentThread
.CurrentUICulture
= New CultureInfo(strLanguageInfo
)
48 Thread
.CurrentThread
.CurrentCulture
= CultureInfo
.CreateSpecificCulture(strLanguageInfo
)